/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rps.controller;

import bean.entity.Applicants;
import bean.entity.Employees;
import bean.session.ApplicantSessionBean;
import bean.session.InterviewSessionBean;
import bean.session.VacancySessionBean;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import bean.entity.Interviews;
import bean.entity.Vacances;
import java.util.Date;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;

/**
 *
 * @author server
 */
@ManagedBean
@SessionScoped
public class InterviewsManagedBean {

    @EJB
    private VacancySessionBean vacancySessionBean;
    @EJB
    private ApplicantSessionBean applicantSessionBean;
    @EJB
    private InterviewSessionBean interviewSessionBean;
    private List<Interviews> listInterviews;
    private Interviews inter;
    private int count;
    private int param;
    private String p;
    private String names;
    private List<Applicants> listApplicant;
    private List<Vacances> listVacancy;

    /** Creates a new instance of InterviewsManagedBean */
    public InterviewsManagedBean() {
        inter = new Interviews();
    }

    public List<Interviews> findAllInterviews() {
        listVacancy = vacancySessionBean.findAllVacances();
        listApplicant = applicantSessionBean.findAllApplicant();
        Date date = new Date();
        listInterviews = interviewSessionBean.findAllInterviewses("E0002", date);
        return listInterviews;
    }

    public void updateInterview() {
        listVacancy = vacancySessionBean.findAllVacances();
        listApplicant = applicantSessionBean.findAllApplicant();
        applicantSessionBean.updateStatus(listInterviews);
        interviewSessionBean.updateInterViews(listInterviews);
    }

    public void updateOneInterview() {
        listVacancy = vacancySessionBean.findAllVacances();
        listApplicant = applicantSessionBean.findAllApplicant();
        applicantSessionBean.updateOneStatus(inter.getApplicants().getApplicantID(), inter.getInStatus());
        interviewSessionBean.updateOneInterViews(inter);
    }

    /**
     * @return the listInterviews
     */
    public List<Interviews> getListInterviews() {
        return listInterviews;
    }

    /**
     * @param listInterviews the listInterviews to set
     */
    public void setListInterviews(List<Interviews> listInterviews) {
        this.listInterviews = listInterviews;
    }

    /**
     * @return the count
     */
    public int getCount() {
        Date date = new Date();
        count = interviewSessionBean.countInterviews("E0002", date);
        return count;
    }

    public String showInterviewsDetails(Interviews Inter) {
        this.inter = Inter;
        return "pretty:interviewsdetails";
    }

    /**
     * @param count the count to set
     */
    public void setCount(int count) {
        this.count = count;
    }

    /**
     * @return the inter
     */
    public Interviews getInter() {
        return inter;
    }

    /**
     * @param inter the inter to set
     */
    public void setInter(Interviews inter) {
        this.inter = inter;
    }

    /**
     * @return the param
     */
    public int getParam() {
        return param;
    }

    /**
     * @param param the param to set
     */
    public void setParam(int param) {
        this.param = param;
    }

    /**
     * @return the p
     */
    public String getP() {
        return p;
    }

    /**
     * @param p the p to set
     */
    public void setP(String p) {
        this.p = p;
    }

    /**
     * @return the names
     */
    public String getNames() {
        return names;
    }

    /**
     * @param names the names to set
     */
    public void setNames(String names) {
        this.names = names;
    }

    /**
     * @return the listApplicant
     */
    public List<Applicants> getListApplicant() {
        return listApplicant;
    }

    /**
     * @param listApplicant the listApplicant to set
     */
    public void setListApplicant(List<Applicants> listApplicant) {
        this.listApplicant = listApplicant;
    }

    /**
     * @return the listVacancy
     */
    public List<Vacances> getListVacancy() {
        return listVacancy;
    }

    /**
     * @param listVacancy the listVacancy to set
     */
    public void setListVacancy(List<Vacances> listVacancy) {
        this.listVacancy = listVacancy;
    }
}
